package com.ftf.tp.user.interfaces.controller;

import com.ftf.tp.common.core.annotation.ResponseResult;
import com.ftf.tp.user.application.assembler.UserAssembler;
import com.ftf.tp.user.application.dto.ArticleAddDTO;
import com.ftf.tp.user.application.service.UserApplicationService;
import com.ftf.tp.user.application.vo.AuthorVO;
import com.ftf.tp.user.application.vo.UserInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户controller
 *
 * @author tanghao
 * @date 2021/11/30
 */
@Slf4j
@ResponseResult
@RequestMapping("/user")
@RestController
public class UserController {

    @Resource
    private UserApplicationService userApplicationService;


    @GetMapping("/getUserInfo")
    public UserInfoVO getUserInfo() {
        return UserAssembler.INSTANCE.doToVo(userApplicationService.getUserInfo());
    }

    /**
     * 新增文章相关用户操作
     *
     * @param articleAddDTO 新建文章参数
     */
    public void blogAddAboutUser(ArticleAddDTO articleAddDTO) {
        userApplicationService.blogAddAboutUser(articleAddDTO);
    }


    /**
     * 根据id获取作者信息
     *
     * @param authorId 作者id
     */
    public AuthorVO getUserInfoByUserId(Long authorId) {
        return userApplicationService.getUserInfoByUserId(authorId);
    }
}
